<h2><?=tr('System Log')?></h2>
<div class="tools"> <?=tr('Log Level')?> : 
<a href="?level=0" class="<?=$level==0?'selected':''?>"><?=tr('Normal')?></a> - 
<a href="?level=1" class="<?=$level==1?'selected':''?>"><?=tr('Debug')?></a>
</div>
<?php
	$level = (int)$_GET['level'];
	$query = sprintf('
		SELECT * 
		FROM fgs_log 
		WHERE level <= %d
		ORDER BY id DESC
		LIMIT 100',
		$level
	);
	$sql = fgs::sql();
	$sql->query($query);


	$table = new htmlTable();
	$table->setHeader('ip', array(
		'title' => tr('IP'),
		'width'	=> '16ex',
	));
	$table->setHeader('date', array(
		'title' => tr('Date'),
		'width'	=> '25ex',
	));
	$table->setHeader('info', array(
		'title' => tr('Infos'),
	));
	
	while ($row = $sql->getline()) {
		$table->set('ip', $row['ip']);
		$table->set('date', $row['dt']);
		$table->set('info', sprintf('<code>%s</code>', $row['data']));
		$table->push();
	}
	
	echo $table->render();
?>
